import request from '@/utils/request';


export async function pageProd(projectId, params) {
    return request(`/project/${projectId}/prodItem/page`, {
        params,
    });
}

export async function save(projectId, data) {
    return request(`/project/${projectId}/prodItem`, {
        method: "POST",
        data: data
    });
}

export async function update(projectId, prodId, data) {
    return request(`/project/${projectId}/prodItem/${prodId}`, {
        method: "POST",
        data: data
    });
}

export async function getDetail(projectId, prodId) {
    return request(`/project/${projectId}/prodItem/${prodId}`);
}

export async function deleteProd(projectId, prodId) {
    return request(`/project/${projectId}/prodItem/${prodId}`, {
        method: "DELETE",
    });
}

export async function updateIsArchived(projectId, prodId, isArchived) {
    return request(`/project/${projectId}/prodItem/${prodId}/${isArchived}`, {
        method: "POST",
    });
}

export async function addDemandDetail(projectId, prodId, data) {
    return request(`/project/${projectId}/prodItem/${prodId}/demandDetail`, {
        method: "POST",
        data: data
    });
}

export async function saveDemandDetail(projectId, prodId, demandDetailId ,data) {
    return request(`/project/${projectId}/prodItem/${prodId}/demandDetail/${demandDetailId}`, {
        method: "POST",
        data: data
    });
}

export async function listDemandDetail(projectId, prodId) {
    return request(`/project/${projectId}/prodItem/${prodId}/demandDetail`);
}

export async function delDemandDetail(projectId, prodId, demandDetailId) {
    return request(`/project/${projectId}/prodItem/${prodId}/demandDetail/${demandDetailId}`, {
        method: "DELETE"
    });
}